require(['grid', 'topBar', 'layout','date'], function () {

	var postData;

    $('#top').topBar({
        left: [{
            type: 'filter-more',
            dateType:'custom',
            search: function () {
            	 if(getPostData()){	                   
	                   $('#grid').grid('setGridParam', {
                           page:1,
	                       datatype: "json",
	                       postData: postData
	                   }).trigger("reloadGrid");
          	   }
            },
            item: [
                {
                    text: '时间快捷',
                    name1: 'beginTime',
                    name2: 'endTime',
                    type: 'dateLine'
                }
            ]
        }],       
        right: [
            {
                text: '导出',
                type: 'export-btn',
                authority: '',
                item: [
                    {
                        text: 'Excel导出',
                        click: function () {
                        	exportFile('Excel');
                        }
                    },
                    {
                        text: 'PDF导出',
                        click: function () {
                        	exportFile('Pdf');
                        }
                    }
                ]
            }
        ]
    });

    $('body').layout();
    
    function exportFile(suffix){
    	if(getPostData()){
    		if($('#grid').getGridParam("reccount")>0){       
	    		var url = "/capacitorStatus/exportCapacitorStatus"+suffix+".htm";
				$.exportFile(url,postData);
    		}
    		else{
    			$.messager.alert("提示","请先查询数据！","info");
    		}
	    }
    }

    $('#grid').grid({
    	url : "/capacitorStatus/searchCapacitorStatus.htm",
		multiselect:false,
		colModel:[
		    {name: "licPltNo", label:"车牌号",width:60},
			{name: "lineName", label:"运营线路",width:80},
			{name: "organName",label:"所属机构",width:80},
			{name: "rcrdTime", label:"采集时间",width:80},
			{name: "soe", label:"电容SOE", align: "right",width:100},
			{name: "capacityInVtg", label:"超级电容电压", align: "right",width:120},
			{name: "capacityInEltCrt", label:"超级电容电流", align: "right",width:120}]
    });
    
    //获取左侧选择的节点信息
	function getPostData(){
        var rcx = commonFun.getTreeCheckNodeToArgs();
        if (rcx) {
            postData = $.extend(rcx, $("#top").parent().getValues());
        }
        return rcx;
	}

})
